package com.jeecg.p3.system.service.impl;

import com.jeecg.p3.system.dao.CourseEvaluateDao;
import com.jeecg.p3.system.entity.CourseEvaluate;
import com.jeecg.p3.system.entity.JwSystemRole;
import com.jeecg.p3.system.service.CourseEvaluateService;
import org.jeecgframework.p3.core.utils.common.PageList;
import org.jeecgframework.p3.core.utils.common.PageQuery;
import org.jeecgframework.p3.core.utils.common.PageQueryWrapper;
import org.jeecgframework.p3.core.utils.common.Pagenation;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @program: jeewx-boot-parent
 * @description: 课程评价业务管理
 * @author: binbin
 * @create: 2020-09-21 10:11
 */
@Service("courseEvaluateService")
public class CourseEvaluateServiceImpl implements CourseEvaluateService {

    @Resource
    private CourseEvaluateDao courseEvaluateDao;

    @Override
    public void doAdd(CourseEvaluate courseEvaluate) {
        courseEvaluateDao.insert(courseEvaluate);
    }

    @Override
    public void doEdit(CourseEvaluate courseEvaluate) {
        courseEvaluateDao.update(courseEvaluate);
    }

    @Override
    public void doDelete(Long id) {
        courseEvaluateDao.delete(id);
    }

    @Override
    public CourseEvaluate queryById(Long id) {
        return courseEvaluateDao.get(id);
    }

    @Override
    public PageList<CourseEvaluate> queryPageList(PageQuery<CourseEvaluate> pageQuery) {
        PageList<CourseEvaluate> result = new PageList<CourseEvaluate>();
        Integer itemCount = courseEvaluateDao.count(pageQuery);
        PageQueryWrapper<CourseEvaluate> wrapper = new PageQueryWrapper<CourseEvaluate>(pageQuery.getPageNo(), pageQuery.getPageSize(),itemCount, pageQuery.getQuery());
        List<CourseEvaluate> list = courseEvaluateDao.queryPageList(wrapper);
        Pagenation pagenation = new Pagenation(pageQuery.getPageNo(), itemCount, pageQuery.getPageSize());
        result.setPagenation(pagenation);
        result.setValues(list);
        return result;
    }
}
